package com.axun.ckz.yytmanager.net;


import com.example.vuandroidadsdk.okhttp.CommonOkHttpClient;
import com.example.vuandroidadsdk.okhttp.listener.DisposeDataHandle;
import com.example.vuandroidadsdk.okhttp.listener.DisposeDataListener;
import com.example.vuandroidadsdk.okhttp.request.CommonRequest;
import com.example.vuandroidadsdk.okhttp.request.RequestParams;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.StringReader;
import java.util.List;

/**
 * Created by ckz on 2018/5/1.import com.example.vuandroidadsdk.okhttp.CommonOkHttpClient;
import com.example.vuandroidadsdk.okhttp.listener.DisposeDataHandle;
import com.example.vuandroidadsdk.okhttp.listener.DisposeDataListener;
import com.example.vuandroidadsdk.okhttp.request.CommonRequest;
import com.example.vuandroidadsdk.okhttp.request.RequestParams;
 */

public class PostRequest {

    private static PostRequest instance;

    public static PostRequest getInstance(){
        if (instance == null){
            synchronized (PostRequest.class){
                if (instance == null){
                    instance = new PostRequest();
                }
            }
        }
        return instance;
    }

    /**
     * 获取code url
     * @param code
     * @param listener
     */
    public void getConfig(String code,DisposeDataListener listener){
        RequestParams params = new RequestParams();
        params.put("code",code);
        CommonOkHttpClient.post(CommonRequest.createPostRequest(URL.CONFIG,params),new DisposeDataHandle(listener));
    }

    /**
     * 登录
     * @param username
     * @param password
     * @param clientId
     * @param listener
     */
    public void login(String username,String password,String clientId,DisposeDataListener listener){
        RequestParams params = new RequestParams();
        params.put("username",username);
        params.put("password",password);
        params.put("client",clientId);
        HttpUtil.post(URL.DOMAIN+URL.Servet.LOGIN,params,listener);
    }


}
